package com.hmdp.utils;
import com.hmdp.dto.UserDTO;
import org.springframework.web.servlet.HandlerInterceptor;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;



//拦截，登入校验用户信息

public class LoginInterceptor implements HandlerInterceptor {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler){
        UserDTO user = UserHolder.getUser();
        if (user==null){
            response.setStatus(401);
            return false;
        }
        return true;
    }

}
